import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { BrokerageConfigVo, BrokerageConfigForm, BrokerageConfigQuery } from '@/api/brokerage/config/types';

/**
 * 查询分销配置列表
 * @param query
 * @returns {*}
 */

export const listBrokerageConfig = (query?: BrokerageConfigQuery): AxiosPromise<BrokerageConfigVo[]> => {
  return request({
    url: '/lawyer/brokerageConfig/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询分销配置详细
 * @param id
 */
export const getBrokerageConfig = (): AxiosPromise<BrokerageConfigVo> => {
  return request({
    url: '/lawyer/brokerageConfig/config',
    method: 'get'
  });
};

/**
 * 新增分销配置
 * @param data
 */
export const addBrokerageConfig = (data: BrokerageConfigForm) => {
  return request({
    url: '/lawyer/brokerageConfig/saveBrokerageConfig',
    method: 'post',
    data: data
  });
};

/**
 * 修改分销配置
 * @param data
 */
export const updateBrokerageConfig = (data: BrokerageConfigForm) => {
  return request({
    url: '/lawyer/brokerageConfig/updateBrokerageConfig',
    method: 'post',
    data: data
  });
};

/**
 * 删除分销配置
 * @param id
 */
export const delBrokerageConfig = (id: string | number | Array<string | number>) => {
  return request({
    url: '/lawyer/brokerageConfig/removeBrokerageConfig/' + id,
    method: 'delete'
  });
};
